package utils

import (
	"encoding/json"
	"strings"
)

func ObjToMap(source interface{}) map[string]string {

	targe := map[string]string{}

	buff, err := json.Marshal(source)

	if err != nil {
		panic(err)
	}

	err = json.Unmarshal(buff, &targe)

	if err != nil {
		panic(err)
	}

	return targe

}

type T interface {
	TableName() string
}

func MapToObj(rows *map[string]string, t T) {
	buff, err := json.Marshal(rows)

	if err != nil {
		panic(err)
	}

	err = json.Unmarshal(buff, t)

	if err != nil {
		panic(err)
	}

}

func SetDirtyTypes(args []string) string {
	return strings.Join(args, ",")
}
